Repository navigation
feat(core): add Forbid create object and Forbid edit object space permissions - #11149
MichaelUray wants to merge 4 commits into
Conversation
…missions Space type roles could only forbid deleting objects. Add two more space-scoped forbid permissions, 'Forbid create object' (TxCreateDoc) and 'Forbid edit object' (TxUpdateDoc, which also covers mixin attribute updates), and offer them in all space types that already offer 'Forbid delete object'. They are enforced server-side by SpacePermissionsMiddleware like the existing forbid permission and apply to all objects inside the space, including comments and attachments. Two adjustments in the middleware: - these generic create/update forbids are not applied to the space document itself, so role holders can still manage members, role assignments and archiving of the space; - when several matching permissions without txMatch apply, a forbidding one now wins instead of depending on the role/permission order. On the client, canCreateObject and canChangeDoc (used by inline attribute editors, drive and card) honour the new permissions. Fixes hcengineering#9079 Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
c372297 to
6269ddd
Compare
|
@MichaelUray Thanks, the middleware change is small and the tests are welcome. A few questions:
|
… space forbids Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
The server now lets a forbidding permission win over an allowing one, so a role with Forbid delete object and a class delete permission (e.g. Drive 'Remove file') can no longer delete. canRemoveDoc only looked at class-specific delete permissions and still offered Delete, which then failed. Check the generic delete forbid first, like canCreateObject and canChangeDoc do for the create and edit forbids. Add unit tests for the forbid checks in canRemoveDoc, canCreateObject and canChangeDoc. Signed-off-by: Michael Uray <michaeluray@users.noreply.github.com>
|
Thanks for the review. Answers in order:
Also changed:
Verification (head 53090ee): local CI is green (install, build, validate, svelte-check, format, unit tests including |
Fixes #9079
Summary
Space type roles could only forbid deleting objects. This adds two space-scoped permissions, "Forbid create object" and "Forbid edit object", offered in every space type that already offers "Forbid delete object" (tracker, document, drive, board, recruit, lead, test management, GitHub).
Changes
core.permission.ForbidCreateObject(TxCreateDoc) andcore.permission.ForbidUpdateObject(TxUpdateDoc), with labels and descriptions in all locales.SpacePermissionsMiddleware):TxMixin(mixin attribute updates). Collection transactions are the childTxCreateDoc/TxUpdateDocproduced bycreateTxCollectionCUDand are checked the same way.objectSpace, so an update that moves an object out of a space where the member has "Forbid edit object" is rejected.txMatchmatch, a forbidding one now wins instead of the last one in order. A matchingtxMatchpermission keeps precedence.modifiedBy), and trigger output (activity, notifications, collection and move side effects) goes through the derived entry below this middleware.view-resources/src/permissions.ts):canCreateObjectreturns false for "Forbid create object" andcanRemoveDocfor "Forbid delete object", before either looks at class permissions.canChangeDocreturns false for "Forbid edit object" only after its existing checks of the class's own${_class}_forbidden/${_class}_allowedpermissions, so such an explicit class allow still makes the object editable in the UI. The existing earlytrueresults of all three helpers (permissions disabled, whitelisted space) are unchanged.Behaviour changes and limitations
txMatch(e.g. Drive "Remove file"), the outcome used to depend on permission order. Now the forbid always wins. The Drive UI follows this throughcanRemoveDoc.TimeSpendReport). "Forbid edit object" blocks editing them too.Tests
foundations/server/packages/middleware/src/__tests__/spacePermissions.test.ts:TxFactory)plugins/view-resources/src/__tests__/permissions.test.ts:txMatch), with allow-only controlsVerification (head 53090ee): local CI is green (install, build, validate, svelte-check, format, unit tests including
middlewarespacePermissions tests andview-resourcespermissions.test.ts, bundle). Browser checks on a local stack with two members, identical in Chromium, Firefox and WebKit: 9 checks pass — for a restricted member the server rejects a custom (mixin) field edit, creating and editing a comment, and moving an issue out of the project, and nothing is saved (verified after a reload), while an unrestricted member can do the same; managing members, role assignments and archiving the project keep working under both forbids; notifications and activity are still delivered. Not automated: attachment metadata editing, the system-session path, and the delete-precedence orderings (the Tracker role picker cannot assign an explicit delete allow); these are covered by the unit tests. Two observations: the attachment-create check could not locate the upload control reliably in this run, and, as noted above, several still-enabled editors give no visible error when the server rejects the change.